home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 2000 July / macformat-092.iso / Fireworks 3 / Settings / HTML Code / Dreamweaver 3 Library.lbi / slices.htt
Encoding:
Text File  |  1999-11-19  |  21.1 KB  |  734 lines

  1. // Fireworks Dreamweaver 3.0 Library HTML & JavaScript for sliced output.
  2. // Version 3.0 23JUL99
  3.  
  4.  
  5. // To export HTML without comments change the value of variable doComments to "false".
  6. var doComments = true;
  7.  
  8. // These are the suffixes for the first 4 frames
  9. var sfx = new Array();
  10. sfx[0] = "";        // first frame doesn't normally have a suffix.
  11. sfx[1] = "_f2";        // second frame.
  12. sfx[2] = "_f3";        // third frame.
  13. sfx[3] = "_f4";        // fourth frame.
  14. var numSFX = 4;
  15. function UpdateFileNames(curSlices) {
  16.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  17.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  18.             if (curSlices[curRow][curCol].skipCell) continue;
  19.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  20.             if (nestedTable) {
  21.                 UpdateFileNames(nestedTable);
  22.                 continue;
  23.             }
  24.             var curSlice = curSlices[curRow][curCol];
  25.             var cellName = "";
  26.             if (curSlice && curSlice.getFrameFileName(0)) {
  27.                 cellName = curSlice.getFrameFileName(0).toString();
  28.                 var i;
  29.                 var limit = exportDoc.numFrames;
  30.                 if (limit > numSFX) limit = numSFX;
  31.                 for (i=0; i<limit; i++) {
  32.                     if (curSlice.getFrameFileName(i)) {
  33.                         curSlice.setFrameFileName(i, cellName + sfx[i]);
  34.                     }
  35.                 }
  36.             }
  37.         }
  38.     }
  39. }
  40. UpdateFileNames(slices);
  41.  
  42.  
  43. var doHeader = false;
  44. // When doComments is set to "true" the WRITE_HTML_COMMENT and WRITE_JS_COMMENT functions
  45. // include HTML and JavaScript comments in the exported file.
  46. function WRITE_HTML_COMMENT(str) {
  47.     if (doComments) WRITE_HTML("<!--"+str+"-->\n");
  48. }
  49.  
  50. function WRITE_JS_COMMENT(str) {
  51.     if (doComments) WRITE_HTML("/* "+str+" */\n");
  52. }
  53.  
  54. // Declare variables for processing Behaviors.    
  55. var kActionStatusMessage = 1;
  56. var kActionSwapImage = 2;
  57. var kActionButtonDown = 4;
  58. var kActionSwapImageRestore = 5;
  59. var kActionButtonHighlight = 6; 
  60. var kActionButtonRestore = 7;
  61.  
  62.  
  63. var kEventMouseOver = 0;
  64. var kEventOnClick = 1;
  65. var kEventMouseOut = 2;
  66. var kEventOnLoad = 3;
  67.  
  68. var hasStatusMessage = false;
  69. var hasSwap = false;
  70. var hasDown = false;
  71. var hasRestore = false;
  72.  
  73. // Write HTML target and date created.
  74. var d = new Date();
  75. WRITE_HTML("<!-- Fireworks 3.0  Dreamweaver 3.0 LBI target.  Created ", d, " -->\n");
  76. WRITE_HTML("\n");
  77.  
  78. // Function cellName determines the name for the image in a particular table cel
  79. // cellName is based off of the slice name if one was specified. Otherwise the
  80. // Base file name from the export dialog is used.
  81. function CellName(curSlices, row, col) {
  82.     var curSlice = curSlices[row][col];
  83.     var cellName = "";
  84.     if (curSlice && curSlice.getFrameFileName(0)) {
  85.         cellName = curSlice.getFrameFileName(0).toString();
  86.         curSlice.setFrameFileName(0, cellName);
  87.         // remove illegal characters
  88.         cellName = cellName.replace(/\W/g, "");
  89.         // if it starts with a number, add N to the front.
  90.         if (cellName == "") cellName = "n" + exportDoc.imagename + "_" + (row+1) + "_" + (col+1);
  91.         if (cellName.search(/\d/) == 0) {
  92.             cellName = "n"+cellName;
  93.         }
  94.     }
  95.     if (cellName!="") return(cellName);     
  96.  
  97.     var prefix;
  98.     if (!curSlices) return("nullCellName");
  99.     if (curSlices.id == 0) {
  100.         prefix = "";
  101.     } else {
  102.         prefix = curSlices.id+"_";
  103.     }
  104.     var suffix="";
  105.     if (curSlices.numRows > 1 || curSlices.numColumns > 1) {
  106.         suffix = "_" + (row+1) + "_" + (col+1);
  107.     }
  108.     cellName = "n" + prefix + exportDoc.imagename + suffix;
  109.     return(cellName);
  110. }
  111.  
  112. // Determine and process Behaviors in the document.
  113. function ProcessEvent(theCurBehaviors, targetEvent) {
  114.     // Declare variable for processing Behaviors.
  115.     var javaScript = "";
  116.     var stat = false;
  117.     var eraseStatOnMouseOut = false;
  118.     var swapImage = "";
  119.     var nbHighlight = "";
  120.     var nbHighlightPreload = false;
  121.     var nbDown = "";
  122.     var nbDownPreload = false;
  123.     var swap = "";
  124.     var swapRestore = false;
  125.     var buttonRestore = false;
  126.     
  127.     // Translate Behaviors into JavaScript.
  128.     for (var i=0; i<theCurBehaviors.numberOfBehaviors; i++) {
  129.         curBehavior = theCurBehaviors[i];
  130.         
  131.         if (curBehavior.ignoreFlag) continue;
  132.         // Check for erase on mouse out status messages.
  133.         if (curBehavior.action == kActionStatusMessage) {
  134.             if (curBehavior.restoreOnMouseout) eraseStatOnMouseOut=true;
  135.         }
  136.         
  137.         if (curBehavior.event != targetEvent) continue;
  138.         
  139.         if (curBehavior.action == kActionStatusMessage) {
  140.             var statMsg = curBehavior.statusText;
  141.             var curStat = "";
  142.             curStat = "MM_displayStatusMsg('" + statMsg + "');";
  143.             javaScript += curStat;
  144.             stat = true;
  145.             continue;
  146.         }
  147.         if (curBehavior.action == kActionSwapImageRestore) {
  148.             swapRestore = true;
  149.             continue;
  150.         }
  151.         
  152.         if (curBehavior.action == kActionButtonRestore) {
  153.             buttonRestore = true;
  154.             continue;
  155.         }
  156.         
  157.         var swapRow = curBehavior.targetRowNum;
  158.         var swapCol = curBehavior.targetColumnNum;
  159.         var swapFrame = curBehavior.targetFrameNum; 
  160.         var swapTable = curBehavior.targetTable;
  161.         var fileName;
  162.         if (!swapTable) {
  163.             /* Not a swap behavior, so continue. */
  164.             continue;
  165.         }
  166.  
  167.         if (curBehavior.hasHref) {
  168.             fileName = curBehavior.href;
  169.         } else {
  170.             fileName = swapTable.imagesDirPath + swapTable[swapRow][swapCol].getFrameFileName(swapFrame) + swapTable[swapRow][swapCol].imageSuffix;
  171.         }
  172.  
  173.  
  174.         var cellName = CellName(swapTable, swapRow,swapCol);
  175.         
  176.         // Translate button Behaviors into JavaScript.
  177.         if (curBehavior.action == kActionButtonDown) {
  178.             //MM_nbGroup(event, groupName, imgName, downSrc...preloadMarker)
  179.             nbDown += "'" + cellName + "','" + fileName + "',";
  180.             if (curBehavior.preload) nbDownPreload = true;
  181.             continue;
  182.         }
  183.         // Translate button Behaviors into JavaScript.
  184.         if (curBehavior.action == kActionButtonHighlight) {
  185.             var highlightName = "";
  186.             if (curBehavior.downHighlight) {
  187.                 if (curBehavior.hasDhHref) {
  188.                     highlightName = curBehavior.dhHref;
  189.                 } else {
  190.                     var f = curBehavior.dhTargetFrameNum;
  191.                     highlightName = swapTable.imagesDirPath + swapTable[swapRow][swapCol].getFrameFileName(f) + swapTable[swapRow][swapCol].imageSuffix
  192.                 }
  193.             }            
  194.             nbHighlight += "'" + cellName + "','" + fileName + "','" + highlightName +"',";
  195.             if (curBehavior.preload) nbHighlightPreload = true;
  196.             continue;
  197.         }
  198.         // Translate Swap Image Behaviors into JavaScript.
  199.         if (curBehavior.action == kActionSwapImage) {
  200.             swap += "'" +cellName +"','','" + fileName + "',";
  201.             continue;
  202.         }        
  203.     }
  204.      if (nbDown != "") {
  205.         if (targetEvent == kEventOnLoad) {
  206.             javaScript += "MM_nbSetInitDown('navbar1'," + nbDown
  207.         } else {
  208.             javaScript += "MM_nbGroup('down','navbar1'," + nbDown
  209.         }
  210.         if (nbDownPreload) {
  211.             javaScript += "1);";
  212.         } else {
  213.             javaScript += "0);";
  214.         }
  215.     }
  216.      if (nbHighlight != "") {
  217.         javaScript += "MM_nbGroup('over'," + nbHighlight
  218.         if (nbHighlightPreload) {
  219.             javaScript += "1);";
  220.         } else {
  221.             javaScript += "0);";
  222.         }
  223.     }
  224.     if (swap != "") {
  225.         javaScript += "MM_swapImage(" + swap + "1);";
  226.     }
  227.     if (swapRestore) {
  228.         javaScript += "MM_swapImgRestore();";
  229.     }
  230.     if (buttonRestore) {
  231.         javaScript += "MM_nbGroup('out');";
  232.     }
  233.     // Erase status bar message onMouseOut.
  234.     if (eraseStatOnMouseOut && targetEvent == kEventMouseOut) {
  235.         javaScript += "MM_displayStatusMsg(' ');" ;
  236.         stat = true;
  237.     }
  238.     
  239.     if (stat) javaScript += "return document.MM_returnValue";
  240.     return(javaScript);
  241. }
  242.  
  243. // Determine and process Behaviors in the document.
  244. function ProcessBehavior(theCurBehaviors) {
  245.     
  246.     javaOver = ProcessEvent(theCurBehaviors, kEventMouseOver);
  247.     javaOut = ProcessEvent(theCurBehaviors, kEventMouseOut);
  248.     javaClick = ProcessEvent(theCurBehaviors, kEventOnClick);
  249.     if (javaOver != "" || javaOut != "" || javaClick != "") {
  250.         return(true);
  251.     }
  252.     return(false);
  253. }
  254.  
  255. function DoFile(curBeh) {
  256.     var swapRow = curBeh.targetRowNum;
  257.     var swapCol = curBeh.targetColumnNum;
  258.     var swapFrame = curBeh.targetFrameNum; 
  259.     var swapTable = curBeh.targetTable;
  260.     if (!swapTable) return;
  261.     var fileName = swapTable[swapRow][swapCol].getFrameFileName(0);
  262.     if (curBeh.downHighlight && curBeh.hasDhTargetFrame) {
  263.         var fm = curBeh.dhTargetFrameNum;
  264.         if (!swapTable[swapRow][swapCol].getFrameFileName(fm)) {
  265.             var tmp;
  266.             var frame = fm+1;
  267.             if (fm < 4) {
  268.                 tmp = fileName + sfx[fm];
  269.             } else {
  270.                 tmp = fileName + "_f" + frame;
  271.             }
  272.             swapTable[swapRow][swapCol].setFrameFileName(fm, tmp);
  273.         }
  274.     }
  275.     if (curBeh.hasTargetFrame && swapFrame > 0) {
  276.         if (swapTable[swapRow][swapCol].getFrameFileName(swapFrame)) return;
  277.         var frame = swapFrame + 1;
  278.         if (swapFrame < 4) {
  279.             fileName = fileName + sfx[swapFrame];
  280.         } else {
  281.             fileName = fileName + "_f" + frame;
  282.         }
  283.         swapTable[swapRow][swapCol].setFrameFileName(swapFrame, fileName);
  284.     } 
  285. }
  286.  
  287.  
  288. // Examine all behaviors to determine what actions are present. 
  289. // Determine which files to pre-cache.
  290. var FWLoadInit = "";
  291. function DoFileAndPreload(curSlices) {
  292.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  293.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  294.             if (curSlices[curRow][curCol].skipCell) continue;
  295.             var nestedTable = curSlices[curRow][curCol].nestedTableSlices;
  296.             if (nestedTable) {
  297.                 DoFileAndPreload(nestedTable);
  298.                 continue;
  299.             }
  300.             if (curSlices[curRow][curCol].behaviors.numberOfBehaviors > 0) {
  301.                 var behaviors = curSlices[curRow][curCol].behaviors;
  302.                 for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  303.                     var curBehavior = behaviors[i];
  304.                     if (curBehavior.action == kActionSwapImage) {
  305.                         DoFile(curBehavior);
  306.                         hasSwap = true;
  307.                     }
  308.                     if (curBehavior.action == kActionButtonDown) {
  309.                         DoFile(curBehavior);
  310.                         hasDown = true;
  311.                     }
  312.                     if (curBehavior.action == kActionButtonHighlight) {
  313.                         DoFile(curBehavior);
  314.                         hasDown = true;
  315.                     }
  316.                     if (curBehavior.action == kActionButtonRestore) {
  317.                         DoFile(curBehavior);
  318.                         hasDown = true;
  319.                     }
  320.                     if (curBehavior.action == kActionSwapImageRestore) {
  321.                         hasRestore = true;
  322.                     }
  323.                     if (curBehavior.action == kActionStatusMessage) {
  324.                         hasStatusMessage = true;
  325.                     }
  326.                 }
  327.                 var init = ProcessEvent(behaviors, kEventOnLoad) ;
  328.                 if (init != "") {
  329.                     FWLoadInit += init;
  330.                 }
  331.             }
  332.             var imagemap = curSlices[curRow][curCol].imagemap;
  333.             for (var j=0; j < imagemap.numberOfURLs; j++) {
  334.                 var curImagemap = imagemap[j];
  335.                 var behaviors = curImagemap.behaviors;
  336.                 for (var i=0; i<behaviors.numberOfBehaviors; i++) {
  337.                     var curBehavior = behaviors[i];
  338.                     if (curBehavior.action == kActionSwapImage) {
  339.                         DoFile(curBehavior);
  340.                         hasSwap = true;
  341.                     }
  342.                     if (curBehavior.action == kActionButtonDown) {
  343.                         DoFile(curBehavior);
  344.                         hasDown = true;
  345.                     }
  346.                     if (curBehavior.action == kActionButtonHighlight) {
  347.                         DoFile(curBehavior);
  348.                         hasDown = true;
  349.                     }
  350.                     if (curBehavior.action == kActionButtonRestore) {
  351.                         DoFile(curBehavior);
  352.                         hasDown = true;
  353.                     }
  354.                     if (curBehavior.action == kActionSwapImageRestore) {
  355.                         hasRestore = true;
  356.                     }
  357.                     if (curBehavior.action == kActionStatusMessage) {
  358.                         hasStatusMessage = true;
  359.                     }
  360.                 }
  361.                 var init = ProcessEvent(behaviors, kEventOnLoad) ;
  362.                 if (init != "") {
  363.                     FWLoadInit += init;
  364.                 }
  365.             }
  366.         }
  367.     }
  368. }
  369.  
  370. DoFileAndPreload(slices);
  371.     
  372.  
  373. function WriteTable(curSlices, indent) {
  374.     var needTable = curSlices.numRows > 1 || curSlices.numColumns > 1;
  375.     var curCol;
  376.     var curRow;
  377.     var downIndex = 0;
  378.     if (needTable) {
  379.         WRITE_HTML("<table ");
  380.  
  381.         // If the Fireworks document's canvas is not transparent and the Include undefined curSlices checkbox
  382.         // is off, give the table a background color based on the FIreworks document's canvas color.
  383.         if (!exportDoc.backgroundIsTransparent && curSlices.doSkipUndefined) {
  384.             WRITE_HTML("bgcolor=\"#", exportDoc.backgroundColor, "\"");
  385.         } 
  386.  
  387.         WRITE_HTML("border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"",
  388.                 curSlices.width, "\">\n");
  389.  
  390.         /* This is the magic comment for html update. */
  391.         if (indent == "") {
  392.             //<--- fwtable fwsrc="mydoc" fwbase="basename" --->
  393.             var comment = "<!-- fwtable fwsrc=\"" + exportDoc.docSaveName + "\" fwbase=\"" + exportDoc.filename + "\"" + " -->\n";
  394.             WRITE_HTML(comment);
  395.         }
  396.  
  397.  
  398.         
  399.     // If shims have been specified, write shim row.    
  400.         if (curSlices.doShimEdges) {
  401.             WRITE_HTML(indent+"  <tr>\n");
  402.             WRITE_HTML_COMMENT(" Shim row, height 1. ");
  403.             for (curCol = 0; curCol < curSlices.numColumns; curCol++) {
  404.                 WRITE_HTML(indent+"   <td><img src=\"", curSlices.shimPath, "\" width=\"", 
  405.                     curSlices[0][curCol].cellWidth, "\" height=\"1\" border=\"0\"></td>\n"); 
  406.             }
  407.             WRITE_HTML(indent+"   <td><img src=\"", curSlices.shimPath, "\" width=\"1", 
  408.                 "\" height=\"1\" border=\"0\"></td>\n"); 
  409.             WRITE_HTML(indent+"  </tr>\n");
  410.             WRITE_HTML("\n");
  411.         }
  412.     }
  413.     // Write table rows.
  414.     for (curRow = 0; curRow < curSlices.numRows; curRow++) {
  415.         if (needTable) {
  416.             WRITE_HTML(indent+"  <tr valign=\"top\">");
  417.             WRITE_HTML_COMMENT(" row "+(curRow+1)+" ");
  418.         }
  419.         for (curCol = 0; curCol < curSlices.numColumns; curCol++) {
  420.             var curSlice = curSlices[curRow][curCol];
  421.             if (curSlice.skipCell) continue; 
  422.  
  423.             if (needTable) {
  424.                 // Write rowspan and colspan if necessary. Ex: rowspan="1" colspan="3"
  425.                 WRITE_HTML(indent+"   <td");
  426.                 if (curSlice.rowSpan > 1) {
  427.                     WRITE_HTML(" rowspan=\"", curSlice.rowSpan,"\"");
  428.                 }
  429.                 if (curSlice.columnSpan>1) {
  430.                     WRITE_HTML(" colspan=\"", curSlice.columnSpan, "\"");
  431.                 }
  432.                 WRITE_HTML(">");
  433.             }
  434.  
  435.             var nestedTable = curSlice.nestedTableSlices;
  436.             if (nestedTable) {
  437.                 WriteTable(nestedTable, "    "+indent);
  438.                 if (needTable) {
  439.                     WRITE_HTML("</td>");
  440.                 }
  441.                 WRITE_HTML("\n");
  442.                 continue;
  443.             }
  444.  
  445.             // Write HTML text from curSlices set to "Text (No Image)"
  446.             if (!curSlice.hasImage) {
  447.                 // no image, just dump out html text.
  448.                 if (curSlice.htmlText) {
  449.                     WRITE_HTML(curSlice.htmlText);
  450.                 } else if (needTable) {
  451.                     WRITE_HTML("<img src=\"",
  452.                         curSlices.shimPath, "\" width=\"", curSlice.width, "\" height=\"", 
  453.                         curSlice.height, "\" border=\"0\">"); 
  454.                 }
  455.                 if (needTable) WRITE_HTML("</td>\n");
  456.                 continue;
  457.             }
  458.  
  459.             // If current slice is not defined by a slice object and Export Undefined
  460.             // curSlices is not checked, don't output an image and if Shims are specified 
  461.             // place a shim image in the current cel
  462.             if (curSlice.isUndefined && curSlices.doSkipUndefined) {
  463.                 if (needTable) {
  464.                     WRITE_HTML("<img src=\"",
  465.                         curSlices.shimPath, "\" width=\"", curSlice.width, "\" height=\"", 
  466.                         curSlice.height, "\" border=\"0\">"); 
  467.                     WRITE_HTML("</td>\n");
  468.                 }
  469.                 // Tell Fireworks to not write the image file. Setting the filename to "" forces 
  470.                 // Fireworks to not generate the image.
  471.                 var q;
  472.                 for (q=0; q<exportDoc.numFrames; q++) {
  473.                     curSlice.setFrameFileName(q, "");
  474.                 }    
  475.                 continue;
  476.             }
  477.  
  478.             // Write link if slice has URL attached.
  479.             var href = "href=\"#\"";
  480.             var hasHref = curSlice.hasHref;
  481.             var abortHref = false;
  482.             if (curSlice.hasHref) {
  483.                 href = "href=\"";
  484.                 href += curSlice.href;
  485.                 href += "\"";
  486.                 if (curSlice.hasTargetText) {
  487.                     href += " target=\"";
  488.                     href += curSlice.targetText;
  489.                     href += "\"";
  490.                 }
  491.                 
  492.                 // If exporting demo HTML, ignore the URL and replace with none.
  493.                 if (curSlices.doDemoHTML && curSlice.getFrameFileName(2)) {                    
  494.                     hasHref = false;
  495.                     href = "href= \"#\"";
  496.                 }
  497.             }
  498.  
  499.             var cellName = CellName(curSlices, curRow, curCol);
  500.             var anchorTagOpen = false;
  501.  
  502.             // If the slice has image map hotspots and has a url attached to it,
  503.             // ignore the url here and move it into the image map.
  504.             if (curSlice.hasImage && curSlice.hasImagemap) {
  505.                 abortHref = true;  // we will put the href in the imagemaps.
  506.             }
  507.  
  508.             // Write rollover and swap image events.
  509.             if (!abortHref) {
  510.                 var behaviors = curSlice.behaviors;
  511.                 var gotJavascript = ProcessBehavior(behaviors);
  512.  
  513.                 if ( gotJavascript || curSlice.hasHref) {
  514.                       WRITE_HTML("<a ");
  515.                     anchorTagOpen = true;
  516.                     WRITE_HTML(href);
  517.  
  518.                     if (javaOut != "") {
  519.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  520.                     }
  521.                     if (javaOver != "") {
  522.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  523.                     }
  524.                     if (javaClick != "") {
  525.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  526.                     }
  527.                     WRITE_HTML(">");
  528.                 }
  529.             }
  530.  
  531.             // Place image.
  532.             if (curSlice.hasImage) {
  533.                 var imageName = curSlice.getFrameFileName(0); 
  534.                 var altText = "";
  535.                 if (curSlice.hasAltText) {
  536.                     altText = curSlice.altText;
  537.                 } else {
  538.                     altText = exportDoc.altText;
  539.                 }
  540.                 
  541.                 // Assemble info for image tag.
  542.                 // Ex: <img name="n_03_02" src="File_03_02.gif" width="79" height="71" border="0"
  543.                 WRITE_HTML("<img name=\"", cellName, "\" src=\"",
  544.                     curSlices.imagesDirPath, imageName, curSlice.imageSuffix, "\" width=\"",
  545.                     curSlice.width,"\" height=\"", curSlice.height, "\" border=\"0\"");
  546.                 
  547.                 // Write image map name.
  548.                 // Ex: usemap="#base_r1_c2"
  549.                 if (curSlice.hasImagemap) {     
  550.                     WRITE_HTML(" usemap=\"#m_", imageName, "\""); 
  551.                 }
  552.                 
  553.                 // Write alt text.
  554.                 if (altText != "") {
  555.                     WRITE_HTML(" alt=\"", altText, "\"");
  556.                 }
  557.                 WRITE_HTML(">");    
  558.             }
  559.  
  560.             if (anchorTagOpen) {
  561.                 WRITE_HTML("</a>");    
  562.             }
  563.             if (needTable) WRITE_HTML("</td>\n");    
  564.         }
  565.         
  566.         if (needTable) {
  567.             // Place shim in rightmost column of table.
  568.             if (curSlices.doShimEdges) {
  569.                 /* Write the 1 pixel transparent shim. */
  570.                 WRITE_HTML("   <td><img src=\"",
  571.                     curSlices.shimPath, "\" width=\"1\" height=\"", 
  572.                     curSlices[curRow][0].cellHeight, "\" border=\"0\"></td>\n"); 
  573.             }
  574.             WRITE_HTML(indent+"  </tr>\n");
  575.         }
  576.     }        
  577.     if (needTable) {
  578.         // Close table.
  579.         if (indent!="") WRITE_HTML(indent+"</table>");
  580.     }
  581. }
  582.  
  583. function WriteImagemaps(curSlices, indent) {
  584.     // Traverse all curSlices and generate any image maps needed.
  585.     for (var curRow = 0; curRow < curSlices.numRows; curRow++) {
  586.         for (var curCol = 0; curCol < curSlices.numColumns; curCol++) {
  587.             var curSlice = curSlices[curRow][curCol];
  588.             if (curSlice.skipCell) continue; 
  589.             var nestedTable = curSlice.nestedTableSlices;
  590.             if (nestedTable) {
  591.                 WriteImagemaps(nestedTable, "    "+indent);
  592.                 continue;
  593.             }
  594.             if (curSlice.hasImagemap) {
  595.                 
  596.                 // Write the image map.
  597.                 WRITE_HTML(indent+"<map name=\"m_", curSlice.getFrameFileName(0), "\">\n");
  598.  
  599.                 var i = 0;
  600.                 var imagemap = curSlice.imagemap;
  601.                 while (i < imagemap.numberOfURLs) {
  602.                     var curImagemap = imagemap[i];
  603.  
  604.                     var behaviors = curImagemap.behaviors;
  605.  
  606.                     if (behaviors.numberOfBehaviors==0) {
  607.                         var behaviors = curSlice.behaviors;
  608.                     }
  609.                      javaOver = "";
  610.                     javaOut = "";
  611.                     javaClick = "";
  612.                     var gotJavascript = ProcessBehavior(behaviors);
  613.     
  614.                     // Write the area tag with shape definitions.
  615.                     WRITE_HTML(indent+"<area shape=\"");
  616.                     WRITE_HTML(curImagemap.shape); // Shapes are rect poly and circle
  617.                     WRITE_HTML("\" coords=\"");
  618.                     for (var j=0; j<curImagemap.numCoords; j++) {
  619.                         if (j>0) WRITE_HTML(",");
  620.                         // polygon has n coords.
  621.                         // rect has 2 coords, topLeft, and botomRight.
  622.                         // circle has one coord, center; plus radius.
  623.                         WRITE_HTML((curImagemap.xCoord(j)-curSlice.left), ",", (curImagemap.yCoord(j)-curSlice.top)); 
  624.                     }
  625.                     if (curImagemap.shape == "circle") {
  626.                         // Write the radius for circle hotspots.
  627.                         WRITE_HTML(", ", curImagemap.radius);
  628.                     }
  629.                     WRITE_HTML("\"");
  630.                     var href = " href=\"#\"";
  631.                     if (curImagemap.hasHref) {
  632.                         href = " href=\"";
  633.                         href += curImagemap.href;
  634.                         href += "\"";
  635.                         if (curImagemap.hasTargetText) {
  636.                             href += " target=\"";
  637.                             href += curImagemap.targetText;
  638.                             href += "\"";
  639.                         }
  640.                     }
  641.  
  642.                     WRITE_HTML(href);
  643.                     
  644.                     // Write alt text for hotspot.
  645.                     var altText = "";
  646.                     if (curImagemap.hasAltText) {
  647.                         altText = curImagemap.altText;
  648.                     } else {
  649.                         altText = exportDoc.altText;
  650.                     }
  651.  
  652.                     if (altText!="") {
  653.                         WRITE_HTML(" title=\"", altText, "\"");
  654.                         WRITE_HTML(" alt=\"", altText, "\"");
  655.                     }
  656.  
  657.                     // Write rollover and swap image behaviors.
  658.                     if (javaOut != "") {
  659.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  660.                     }
  661.                     if (javaOver != "") {
  662.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  663.                     }
  664.                     if (javaClick != "") {
  665.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  666.                     }
  667.  
  668.                     WRITE_HTML(" >\n");
  669.                     i++;
  670.                 } 
  671.                 var behaviors = curSlices[curRow][curCol].behaviors;
  672.                  javaOver = "";
  673.                 javaOut = "";
  674.                 javaClick = "";
  675.                 var gotJavascript = ProcessBehavior(behaviors);    
  676.  
  677.                 var link = "";
  678.                 if (curSlice.hasHref) {
  679.                     link = curSlice.href;
  680.                 } else {  
  681.                     if (exportDoc.backgroundLink) {
  682.                         link = exportDoc.backgroundLink.href;
  683.                     }
  684.                 }
  685.  
  686.                 // If the current slice had a URL attached, it was moved and written here.
  687.                 if (gotJavascript || link != "") {
  688.                     WRITE_HTML(indent+"<area shape=\"rect\" coords=\"0,0, ", curSlice.width, ",", curSlice.height, "\" ");
  689.                     var href="#";
  690.                     if (link!="") {
  691.                         href = link;
  692.                     }
  693.                     WRITE_HTML("href=\"", href, "\"");
  694.  
  695.                     if (curSlice.hasTargetText) {
  696.                         WRITE_HTML("\n  target=\"", curSlices[curRow][curCol].targetText, "\"");
  697.                     }
  698.                     if (javaOut != "") {
  699.                         WRITE_HTML(" onMouseOut=\"", javaOut, "\" ");
  700.                     }
  701.                     if (javaOver != "") {
  702.                         WRITE_HTML(" onMouseOver=\"", javaOver, "\" ");
  703.                     }
  704.                     if (javaClick != "") {
  705.                         WRITE_HTML(" onClick=\"", javaClick, "\" ");
  706.                     }
  707.                     var altText = "";
  708.                     if (curSlice.hasAltText) {
  709.                         altText = curSlice.altText;
  710.                     } else {
  711.                         altText = exportDoc.altText;
  712.                     }
  713.                     if (altText!="") {
  714.                         WRITE_HTML(" title=\"", altText, "\"");
  715.                         WRITE_HTML(" alt=\"", altText, "\"");
  716.                     }
  717.                     WRITE_HTML(">\n");
  718.                 }    
  719.  
  720.                 WRITE_HTML(indent+"</map>\n")
  721.                 WRITE_HTML("\n");
  722.             }
  723.         }
  724.     }
  725. }
  726.  
  727. WriteTable(slices, "");
  728. WriteImagemaps(slices, "");
  729.  
  730. var needTable = slices.numRows > 1 || slices.numColumns > 1;
  731. if (needTable) {
  732.     WRITE_HTML("</table>\n");
  733. }
  734.